<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="" />
    <meta name="author" content="ChongMing" />
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="full-screen" content="yes">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="360-fullscreen" content="true">
    <title>会诊</title>
</head>
<link rel="stylesheet" href="../css/framework7.ios.min.css">
<link rel="stylesheet" href="../css/framework7.ios.colors.min.css">
<link rel="stylesheet" href="../css/my-app.css">
<link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="css/consultation.css">
<!--<link rel="stylesheet" href="css/zyUpload.css" type="text/css">-->
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../js/jquery.mobile-1.4.3.js"></script>
<script type="text/javascript" src="../js/framework7.min.js"></script>
<script type="text/javascript" src="../js/my-app.js"></script>
<script type="text/javascript" src="js/consultation.js"></script>
<!--&lt;!&ndash; 引用核心层插件 &ndash;&gt;-->
<!--<script type="text/javascript" src="js/zyFile.js"></script>-->
<!--&lt;!&ndash; 引用控制层插件 &ndash;&gt;-->
<!--<script type="text/javascript" src="js/zyUpload.js"></script>-->
<!--&lt;!&ndash; 引用初始化JS &ndash;&gt;-->
<!--<script type="text/javascript" src="js/demo.js"></script>-->
<script src="js/ap.js"></script>
<script src="js/pingpp.js"></script>
<script>
$(function(){
    $(document).on('click',".upload_append_list",function () {
        if($(this).find(".file_bar").hasClass('file_hover')){
            $(this).find(".file_bar").removeClass("file_hover");
        }else{
            $(this).find(".file_bar").addClass("file_hover");

        }
    });
    if(consultationinterface.getQueryString('reload')==1){
        location.href = 'http://www.ekangjiuyi.net/EKang2.0/hospital_nurse/groupconsultationh-datail.html'
    }
    console.log($.cookie("local_userId"));
//    var uid = consultationinterface.getQueryString('uid');
//    uid = 1499724
    coupon_money = 1;
//    page  js
    consultationinterface.pre_order(decodeURI('['+$.cookie('doctorid')+']'),$.cookie("local_userId"));
    //    点击上传图片
    var $container = $('.groupconsultationh-datail .top-form .pictures .up-button .input-file');
    var up_pic_url = []
    $container.on('change','input[name="photoFile"]',function(e){
        var $this = $(this),
                file = null,
                freader = null;
        for(var i=0;i<e.target.files.length;i++){
            file = e.target.files.item(i);
            //不是图片 跳出这一次循环
            if(!(/^image\/.*$/i.test(file.type)))
            {
                continue;
            }
            //实例化FileReader API
            freader = new FileReader();
            freader.readAsDataURL(file);
            freader.onload = function(e){
                $('.groupconsultationh-datail .top-form .upload-pic p').hide()
//                var len = $('.showimg ul li').length + 1
//                $('.groupconsultationh-datail .top-form .upload-pic .up-icon').attr('src',e.target.result)
                $('.groupconsultationh-datail .top-form .pictures .append-pic').append('<div class="list"><img class="tu" src="' + e.target.result + '"><img class="del" src="images/icon44.png">')
                //$('.showimg ul li .cha').click(function(){
                //    $(this).parent().remove()
                //});
                up_pic_url.push(e.target.result)
//                if($('.groupconsultationh-datail .top-form .pictures .append-pic .list').length>4){
//                    $('.groupconsultationh-datail .top-form .pictures .up-button').hide();
//                }else{
//                    $('.groupconsultationh-datail .top-form .pictures .up-button').show();
//                }
            }
        }
    });
    //    进行会诊点击
    $('.groupconsultationh-datail .conduct-button .conduct').click(function(){
//        $('.payment-layer').show();
//        $('.groupconsultationh-datail .payment-layer .con').animate({'bottom':0},300);
        name_val = $('.groupconsultationh-datail .top-form .name input').val();
        phone_val = $('.groupconsultationh-datail .top-form .phone input').val();
        textarea_val = $('.groupconsultationh-datail .top-form .situation textarea').val();
        time_val = $('.groupconsultationh-datail .bot-form .public input').val();
        price = $('.groupconsultationh-datail .bot-form .money .price').html();
//        case_id = $('.groupconsultationh-datail .top-form .medicalrecord .p-name').attr('data-id');
//        else if(textarea_val==''){
//            consultationinterface.layer('请输入当前详细病情');
//        }
        if($('.groupconsultationh-datail .bot-form .accompany .radio').hasClass('hover')){
            diagnosis_on = 1;
        }else{
            diagnosis_on = 0;
        }
        if($('.groupconsultationh-datail .bot-form .car .radio').hasClass('hover')){
            car_on = 1;
        }else{
            car_on = 0;
        }
        if(name_val==''){
            consultationinterface.layer('请输入患者姓名');
        }else if(phone_val==''){
            consultationinterface.layer('请输入患者手机号');
        }else if(!obj.phone.test(phone_val)){
            consultationinterface.layer('手机号格式错误');
        }else if(time_val==''){
            consultationinterface.layer('请输入时间');
        }else{
//            up_pic_url = []
//            var upimg_l = $('.upload_append .list').length;
//            for(i=0;i<upimg_l;i++){
//                var database = $('.upload_append .list').eq(i).find('.upload_image').attr('src')
//                up_pic_url.push(database);
//                console.log(up_pic_url)
//            }
            $('.groupconsultationh-datail .payment-layer .con .money-num .p2').html('￥ '+price)
            $('.payment-layer').show();
            $('.groupconsultationh-datail .payment-layer .con').animate({'bottom':0},300);
        }
    });
//    优惠券
    $('.navbar .left').click(function(){
        $('.toolbar-through').hide();
        $('.groupconsultationh-datail').show();
    });
    $('.groupconsultationh-datail .payment-layer .con .coupon').click(function(){
        $('.toolbar-through').show();
        $('.groupconsultationh-datail').hide();
        coupon_money = $('.groupconsultationh-datail .bot-form .money .price').html();
        mycenter.getdiagnosis();
    });
//    点击支付
    if($.cookie("is_wechat")==1){
        $('.groupconsultationh-datail .payment-layer .con .pay-mode .wechat').hide();
        $('.groupconsultationh-datail .payment-layer .con .pay-mode .alipay .radio').hide();
        $('.groupconsultationh-datail .payment-layer .con .pay-mode .wechat .radio').removeClass('hover');
        pay_mode = 'alipay_wap';
    }
    $('.groupconsultationh-datail .payment-layer .con .button-pay').click(function(){

        var coupon_id = $('.groupconsultationh-datail .payment-layer .con .coupon .p-left').data('id');

        if($('.groupconsultationh-datail .payment-layer .con .pay-mode .wechat .radio').hasClass('hover')){
            pay_mode = 'wx_pub';
        }else{
            pay_mode = 'alipay_wap';
        }
        var success_url_sp = decodeURI(location.href);
        success_url = success_url_sp.split('?')[0]
        var getdata={uid:$.cookie("local_userId"),remark:textarea_val,doctor_id_arr:decodeURI('['+$.cookie('doctorid')+']'),appointment_time:time_val,coupon_id:coupon_id,user_name:name_val,mobile:phone_val,diagnosis_on:diagnosis_on,car_on:car_on,is_rec:0};
        for(var i=0;i<up_pic_url.length;i++){
            eval("getdata.caseData"+(i+1)+"='"+up_pic_url[i]+"'");
        }
        $.ajax({
            type : 'post',
            url : url+'diagnosis/grpConsultatSubmitOrder',
            dataType : 'json',
            data : getdata,
            success : function(res) {
                var data = res.data;
                var order_id = data.order_id
                if(res.ret==0){
                    console.log(res);
//                    $.ajax({
//                        type: 'GET',
//                        url:  url + '/diagnosis/getcharge/',
//                        data: {         // 需要于客户端同步
//                            uid: $.cookie("local_userId"),
//                            order_id: data.order_id,
//                            pay_method:pay_mode,
//                            success_url:success_url
//                        },
//                        dataType: 'jsonp',
//                        jsonp: 'callback',
//                        success: function (result) {
//                            if(result==0){
//                                alert('ok')
//                            }else{
//                                console.log(result.msg)
//                            }
//                            if(pay_mode == "alipay_wap"){
//                                pingpp.createPayment(result.data.charge, function(result, err) {
//                                    if (result=="success") {
//                                        location.href = 'http://www.ekangjiuyi.net/EKang2.0/myCenter/mycenter_orderList.html?uid='+$.cookie("local_userId")+'';
//                                    } else {
//
//                                    }
//                                });
//                            }else{
//                                var url = result.data.location_url;
//                                location.href = url;
//                            }
//                        }
//                    });
                    code = consultationinterface.getQueryString("code");
                    if(code){
                        $.ajax({
                            type: 'GET',
                            url:  url + '/diagnosis/getcharge/',
                            data: {         // 需要于客户端同步
                                uid: $.cookie("local_userId"),
                                order_id: order_id,
                                pay_method:pay_mode,
                                code : code
                            },
                            dataType: 'jsonp',
                            jsonp: 'callback',
                            success: function (result) {
                                if(result.ret){
                                    alert(result.msg);
                                }
                                pingpp.createPayment(result.data.charge, function(result, err) {
                                    if (result=="success") {
                                        location.href = '../groupconsultation/order_stayDiagnosis.html'
                                    } else {

                                    }
                                });
                            }
                        });
                    }else{
                        $.ajax({
                            type: 'GET',
                            url:  url + '/diagnosis/getcharge/',
                            data: {         // 需要于客户端同步
                                uid: $.cookie("local_userId"),
                                order_id: order_id,
                                pay_method:pay_mode,
                                code : code
                            },
                            dataType: 'jsonp',
                            jsonp: 'callback',
                            success: function (result) {
                                if(result.ret){
                                    alert(result.msg);
                                }
                                pingpp.createPayment(result.data.charge, function(result, err) {
                                    if (result=="success") {
                                        location.href = '../groupconsultation/order_stayDiagnosis.html'
                                    } else {

                                    }
                                });
                            }
                        });
                    }
                }else{
                    console.log(res.msg);
                }
            }
        });
    });
});
</script>
<style type="text/css">
    html {
        overflow: hidden;
    }

    .content-back {
        position: relative;
        background-color: white;
        width:95%;
        height: 63px;
        margin-top: 15px;
        margin-left: 2.5%;
        -moz-box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.16);
        -webkit-box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.16);
        box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.16);
    }

    .content-redImg {
        position: absolute;
        width: 79px;
        height: 63px;
        z-index: 100;
    }

    .content-money {
        font-size: 36px;
        color: #fff;
        line-height: 63px;
        text-align: center;
    }
    .content-money-subText {
        position: absolute;
        font-size: 25px;
        color: #666666;
        top: 5px;
        left: 80px;
    }

    .content-subDetail {
        position: absolute;
        font-size: 9px;
        color: #808080;
        top: 40px;
        left: 80px;
    }

    .content-rightText {
        position: absolute;
        font-size: 9px;
        color: #43af80;
        top: 10px;
        right: 0;
        text-align: right;
    }
</style>
<body style=" background: #ebebeb; max-width:640px; margin: auto;-webkit-overflow-scrolling: touch;overflow: scroll;">
<div class="groupconsultationh-datail">
    <div class="top-form">
        <div class="name public">
            <label>患者姓名：</label>
            <input type="text" placeholder="请输入患者姓名">
        </div>
        <div class="phone public">
            <label>患者手机：</label>
            <input type="number" placeholder="请输入患者手机号">
        </div>
        <!--<div class="medicalrecord">-->
            <!--<label>患者病历：</label>-->
            <!--<p class="p-name" data-id="">选择患者病历</p>-->
            <!--<img src="images/icon37.png">-->
        <!--</div>-->
        <div class="situation">
            <textarea placeholder="请详细描述您当前的病情,如不方便上传相关病例资料，待预约成功之后可配合平台相关工作人员进行资料提交或者进行邮递等方式,具体情况依据患者自身进行协调。易康将确保您的隐私安全"></textarea>
        </div>
        <div class="upload-pic">
            <div class="pictures">
                <div class="append-pic">

                </div>
                <div class="up-button">
                    <img class="up-icon" src="images/icon28.png">
                    <div class="input-file relative">
                        <input class="absolute" type="file" multiple="multiple" id="photoFile" name="photoFile">
                    </div>
                    <input type="hidden" id="blessingpic" name="blessingpic">
                </div>
                <p>如有病历、检查、化验单、疾病部位等<br/>可以拍照上传</p>
                <!--<div id="demo" class="demo"></div>-->
            </div>
        </div>
    </div>
    <div class="bot-form">
        <div class="tit">本次会诊专家</div>
        <div class="doctor-list">
            <div class="win">

            </div>
        </div>
        <div class="startime public">
            <label>会诊开始时间：</label>
            <input type="date">
        </div>
        <div class="contact-number public">
            <label>联系电话：</label>
            <p>4006-305-060</p>
        </div>
        <div class="service public">
            <label>服务人员：</label>
            <p>支付成功2小时可见联系人电话</p>
        </div>
        <div class="accompany public">
            <label>陪诊服务：</label>
            <p>(388元/次，全天服务)</p>
            <div class="radio">
                <div class="slider"></div>
            </div>
        </div>
        <div class="car public">
            <label>专车接驾：</label>
            <p>(150元/次，接驾到医院)</p>
            <div class="radio">
                <div class="slider"></div>
            </div>
        </div>
        <div class="money public">
            <label>实付金额：</label>
            <div class="price"></div>
            <p>(一位专家1500)</p>
        </div>
    </div>
    <div class="conduct-button">
        <button class="conduct">进行会诊</button>
    </div>
    <div class="medicalrecord-layer">
        <div class="con">

        </div>
    </div>
    <div class="payment-layer">
        <div class="topmask"></div>
        <div class="con">
            <!--<div class="name">-->
                <!--<p class="p1">姓名：</p>-->
                <!--<p class="p2">张三李四</p>-->
            <!--</div>-->
            <!--<div class="phone">-->
                <!--<p class="p1">联系电话：</p>-->
                <!--<p class="p2">156 0000 1234</p>-->
            <!--</div>-->
            <div class="coupon">
                <p class="p-left">优惠券</p>
                <img src="images/icon37.png">
            </div>
            <div class="money-num">
                <p class="p1">实付金额</p>
                <p class="p2">￥ 1499</p>
            </div>
            <div class="pay-mode">
                <p class="p1">支付方式</p>
                <div class="wechat public">
                    <img class="icon-wechat img" src="images/icon42.png">
                    <img class="radio hover" src="images/icon41.png">
                </div>
                <div class="alipay public">
                    <img class="icon-alipay img" src="images/icon43.png">
                    <img class="radio" src="images/icon40.png">
                </div>
            </div>
            <!--<span class="contact-time">推荐成功后2小时（工作时间段）可见联系电话</span>-->
            <button class="button-pay">支付</button>
        </div>
    </div>
</div>
<div class="views tabs toolbar-through" style=" display: none; margin-top: 0">
    <!--导航条-->
    <!-- Second view (for second wrap)-->
    <div id="view" class="view view-main tab active">
        <!-- We can make with view with navigation, let's add Top Navbar-->
        <div class="navbar">
            <div class="navbar-inner" style="background-color: #38a16d">
                <div class="left" id="back" style=" left:10px; margin-top: 0">
                    <a href="#" class="back link">
                        <i class="icon icon-back color-white" style="color: white"></i>
                        <span style="color: white">返回</span>
                    </a>
                </div>
                <div class="center sliding" style="color: white; margin: auto; font-weight: normal;">诊疗金</div>
                <!--<div class="right" id="right">-->
                    <!--<span style="color: white">诊疗金使用说明</span>-->
                <!--</div>-->
            </div>
        </div>

        <div class="pages navbar-through">
            <div data-page="index-2" class="page page-on-center">
                <div class="page-content pull-to-refresh-content infinite-scroll">
                    <!-- 默认的下拉刷新层 -->
                    <div class="pull-to-refresh-layer"style=" margin-top: 0px">
                        <div class="preloader"></div>
                        <div class="pull-to-refresh-arrow"></div>
                    </div>

                    <div id="content-list">
                    </div>

                    <!-- 加载提示符 -->
                    <div class="infinite-scroll-preloader">
                        <div class="preloader"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="../js/framework7.min.js"></script>
<script type="text/javascript" src="../js/my-app.js"></script>
<!--<script src="../js/jquery-1.10.2.js"></script>-->
<script src="../js/jquery.cookie.js"></script>
<script src="../js/ekang.js"></script>
<script>
    $(function () {
        var pageIndex = 1;
        mycenter = {
            getdiagnosis: function () {
                $.ajax({
                    type: 'GET',
                    url: textUrl + '/diagnosis/UserCouponList',
                    data: {         // 需要于客户端同步
                        uid : $.cookie("local_userId"),
                        total_amount :coupon_money ,
                        page_size : '15',
                        page_index : pageIndex
                    },
                    dataType: 'jsonp',
                    jsonp: 'callback',
                    success: function (result) {
                        if (result.ret == 0) {
                            var moneyArr = result.data;
                            console.log(moneyArr)
                            var item = '';
                            $.each(moneyArr, function (i, o) {

                                item += '<div class="content-back" data-index="'+ o.is_can_use+'" data-id="'+ o.id +'" data-name="'+ o.amount+'" onclick="diag_money(this)">';
                                if(o.is_can_use == 0){
                                    item += '<img src="../img/mypage_img/coupon_not_can_use.png" alt="红色" class="content-redImg"/>';
                                }else{
                                    item += '<img src="../img/mypage_img/btn_shadowred.png" alt="红色" class="content-redImg"/>';
                                }
                                item += '<span class="content-redImg content-money">'+ o.amount+'</span>';
                                item += '<span class="message content-money-subText">元诊疗金</span>';
                                item += '<span class="message content-subDetail">'+ o.end_on+'过期&nbsp'+ o.name+'</span>';
                                item += '<span class="message content-rightText">'+ o.type_text +'</span>';
                                item += ' </div>';

                            });
//                            $('#content-list').html(item);

                            // 加载完毕需要重置
                            myApp.pullToRefreshDone();

                            // 加载数据
                            // 重置加载flag
                            loading = false;
                            if (lastIndex >= maxItems) {
                                // 加载完毕，则注销无限加载事件，以防不必要的加载
                                myApp.detachInfiniteScroll($('.infinite-scroll'));
                                // 删除加载提示符
                                $('.infinite-scroll-preloader').remove();
                                return;
                            }
                            // 如果正在加载，则退出
                            if (pageIndex >1 ){
                                // 添加新条目
                                $('#content-list').append(item);
                            }else{
                                $('#content-list').html(item);
                            }

                            // 更新最后加载的序号
                            lastIndex = $('#content-list').length;

                            if(result.data.length <= 20){
                                $('.infinite-scroll-preloader').hide();
                            }else{
                                $('.infinite-scroll-preloader').show();
                            }

                        } else {
                            console.log(result.msg);
                        }
                    }
                });
            },
        };
        mycenter.getdiagnosis();


//        $('#back').on('click', function () {
//            history.back();
//        });

        $('#right').on('click', function () {
            location.href = "http://ekang.ren/index/instruction";
        });

        // 刷新
        var myApp = new Framework7();
        var $$ = Dom7;
        // 下拉刷新页面
        var ptrContent = $$('.pull-to-refresh-content');
        // 添加'refresh'监听器
        ptrContent.on('refresh', function (e) {

            pageIndex=1;
            mycenter.getdiagnosis();
        });

        // 加载数据
        var loading = false;
        // 上次加载的序号
        var lastIndex = $('#content-list').length;
        // 最多可加载的条目
        var maxItems = 20;
        // 注册'infinite'事件处理函数
        $$('.infinite-scroll').on('infinite', function () {
            // 如果正在加载，则退出
            if (loading) return;
            // 设置flag
            loading = true;
            pageIndex++;
            mycenter.getdiagnosis();
        });
    });

    function diag_money(e) {
        var id=e.getAttribute("data-id");
        var name=e.getAttribute("data-name");
        var is_can = e.getAttribute("data-index");

        if(is_can == 1){
            $.cookie('dia_name', name, { expires: 7,path: '/' });
            $.cookie('dia_id', id, { expires: 7,path: '/' });
            var allmon = coupon_money-$.cookie('dia_name')
            $('.groupconsultationh-datail .payment-layer .con .coupon .p-left').html('优惠券（'+$.cookie('dia_name')+'）').attr('data-id',$.cookie('dia_id'));
            $('.groupconsultationh-datail .payment-layer .con .money-num .p2').html('￥ '+allmon)
            $('.toolbar-through').hide();
            $('.groupconsultationh-datail').show();
        }else {
            alert("红包已过期,请重新选择");
            return;
        }

    }
</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript"></script>
<script src="../js/weixin2.js"></script>
</body>
</html>